from peewee import CharField, AutoField
from playhouse.mysql_ext import JSONField

from application.db import get_database_connection
from application.db.mysql_db.base_mysql_model import BaseMysqlModel


class CnArticleAbstractInfo(BaseMysqlModel):
    """中文文献库文献摘要信息表"""
    article_id = CharField(max_length=32, index=True)  # 文献ID，表cn_article_list标识
    chs_text = JSONField()  # 中文摘要内容，对于英文文献记录段落译文，格式如[{"section_attr":"段落类型，取值["title"(摘要标题), "abstract"(摘要正文)]", "section_text":"段落文本"}]
    eng_text = JSONField(null=True)  # 英文摘要内容，对于中文文献可为空，格式如[{"section_attr":"段落类型，取值["title"(摘要标题), "abstract"(摘要正文)]", "section_text":"段落文本"}]

    class Meta:
        table_name = 'cn_article_abstract_info'
        database = get_database_connection('default')  # 使用默认数据库


if __name__ == '__main__':
    # 示例查询
    rows = CnArticleAbstractInfo.select()
    for row in rows:
        print(row.article_id, row.chs_text)